package com.hltx.controller.app.account;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hltx.controller.base.BaseController;
import com.hltx.pojo.common.Page;
import com.hltx.pojo.rebateannal.Bill;
import com.hltx.service.rebateannal.BillManager;
import com.hltx.util.MessagesCode;
import com.hltx.util.ResultInfo;

/**
 * APP账单controller
 * 
 * @author 
 *
 */
@Controller
@RequestMapping(value = "/app/")
public class AppAccountController extends BaseController{
	
	@Resource(name="billService")
	private BillManager billService;

	/**
	 * 打开账单列表
	 */
	@RequestMapping(value = "/biiList",method = { RequestMethod.GET, RequestMethod.POST})
	@ResponseBody
	public Map<String, Object> addrebiiListssList(Page page,HttpServletRequest request){
		this.logBefore(logger, "查询账单列表");
		Map<String, Object> resMap = new HashMap<String, Object>();
		String userId = request.getParameter("id");
		int start = (page.getPage()-1) * page.getShowNumber();
		try {
			page.getParams().put("userid", userId);
			page.setStart(start);
			page.setShowNumber(page.getShowNumber());
			List<Bill> billList=billService.getBillList(page);
			if(billList.size()>0){
				resMap.put("billList", billList);
				resMap.put("result", this.initResult(ResultInfo.SUCCESS, MessagesCode.SUCCESS, "查询成功"));
			}else{
				resMap.put("result", this.initResult(ResultInfo.SUCCESS, MessagesCode.PRICE_ERROR, "未产生账单"));
			}
		} catch (Exception e) {
			e.printStackTrace();
			this.logError(logger, e.getMessage());
			resMap.put("result", this.initResult(ResultInfo.ERROR, "exception", "系统异常"));
		}
		this.logAfter(logger);
		return resMap;
	}
}
